import tool from "@/utils/tool";
export function actionToObject(json) {
  try {
    return JSON.parse(json)
  } catch (e) {
    console.log('err', e.message)
  }
  return []
}

/**
 * 控制按钮是否显示
 *
 * @author yubaoshan
 * @date 2020/06/27 02:34
 */
export function hasBtnPermission(permission) {
  // console.log('---s--')
  const userInfo = tool.data.get("USER_INFO")
  console.log(userInfo,';--userInfo')
  const myBtns = userInfo?.permissions
  const admintype = userInfo?.adminType

  console.log(myBtns,'--myBtns')
  console.log(admintype,'--admintype')
  console.log(myBtns != undefined? myBtns.indexOf(permission) > -1 : false)

  if (admintype == '1') {
    return true
  }
  return myBtns != undefined? myBtns.indexOf(permission) > -1 : false
  // return true
}

